/**
 * 逆 经纬度查询
 * @params lat
 * @params lon
 */
const QQ_MAP_KEY = '6FABZ-T75KJ-NLAFI-FB47C-66OEO-3ABE6';
const API_URL = 'https://free-api.heweather.net/s6/weather'
export const geocoder = (lat,lon,success=()=>{},fail=()=>{})=>{
  return wx.request({
    url: 'https://apis.map.qq.com/ws/geocoder/v1/',
    data:{
      location:`${lat},${lon}`,
      key: QQ_MAP_KEY,
      // get_poi: 0,
    },
    success,
    fail
  })
}
export const getWeather = (lat,lon,success=()=>{},fail=()=>{})=>{
  let location = `${lat},${lon}`
  // let params = {
  //   location,
  //   key: 'b858695e450e4eac9ebd16c4189d2fa6' //和风天气中应用的密钥
  // }
  // let query = []
  // for (let i in params) {
  //   query.push(`${i}=${encodeURIComponent(params[i])}`)
  // }
  // let url = API_URL + '?' + query.join('&')
  return wx.request({
    url: API_URL,
    data:{
      location,
      key:'b858695e450e4eac9ebd16c4189d2fa6'
    },
    success,
    fail
  })
}